(function($){
	$.fn.extend({
		"dialog":function(options){
			if(typeof(options)=="object"){
				var template='\
					<div class="modal fade">\
	                	<div class="modal-dialog">\
	                		<div class="modal-content">\
	                			<div class="modal-header">\
	                				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>\
									<h4 class="modal-title"></h4>\
								</div>\
								<div class="modal-body"></div>\
								<div class="modal-footer">\
					                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>\
					                <button type="button" class="btn btn-primary">确定</button>\
	                			</div>\
	                		</div>\
						</div>\
					</div>';
				var opts={
						title:"",
						btnName:"确认",
						btnBind:null
				}
				for(var opt in opts){
					opts[opt]=options[opt]||opts[opt];
				}
				var modal=$(template);
				modal.find(".modal-title").html(opts.title);
				modal.find(".modal-body").append(this);
				modal.find(":button:last").html(opts.btnName);
				modal.find(":button:last").off("click").on("click",opts.btnBind);
				modal.appendTo("body");
			}else if(options=="open"){
				this.parents(".modal").modal("show");
			}else if(options=="close"){
				this.parents(".modal").modal("hide");
			}
		}
	})
})(jQuery);